export default () => {
  chrome.runtime.onInstalled.addListener(() => {
    // Set style.
    chrome.browserAction.setBadgeBackgroundColor({color: '#0BA217'})

    chrome.declarativeWebRequest.onRequest.removeRules(undefined, () => {
      chrome.declarativeWebRequest.onRequest.addRules([{
        conditions: [new chrome.declarativeWebRequest.RequestMatcher({
          url: {
            hostPrefix: 'www.oschina',
            pathEquals: '/question'
          },
          stages: ['onBeforeSendHeaders']
        })],
        actions: [new chrome.declarativeWebRequest.SetRequestHeader({
          name: 'Referer',
          value: 'https://www.oschina.net/'
        })]
      }]);
    })
  })
}